package com.hmdp.handler;

import com.hmdp.dto.Result;
import com.hmdp.exception.BaseException;
import com.hmdp.exception.ShopNotFoundException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 衷岚
 * @version 1.0
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

//    @ExceptionHandler
//    public Result exceptionHandler(BaseException e){
//        //打印错误信息日志
//        log.error(e.getMessage());
//        return Result.fail(e.getMessage());
//
//    }

    @ExceptionHandler(ShopNotFoundException.class)
    public Result exceptionHandler(ShopNotFoundException e){
        log.error(e.getMessage());
        return Result.fail(e.getMessage());
    }
}
